#ifndef SERVERSOCKET_H
#define SERVERSOCKET_H

#include <QObject>
#include <QtNetwork>

#define SERVER_PORT 45454
#define SERVER_ID "electricity_server"
#define CLIENT_ID "electricity_client"


class ServerSocket : public QObject
{
    Q_OBJECT

public:
    explicit ServerSocket(QObject *parent = 0);
    ~ServerSocket();

private:
    void writeLog(QString log);

signals:
    void serverLog(QString log);

private slots:
    void udpGetData();
    void startNetwork();

public slots:
    void enableServerMode();
    void enableClientMode();
    void start();
    void stop();
    void sendToClient(QString msg);


private:
    QNetworkConfigurationManager* iNetworkManager;
    QUdpSocket* iUdpBroadcastSocket;
    QNetworkSession* iNetworkSession;
    bool iWantedToStart;
    bool iServerMode;
};

#endif // SERVERSOCKET_H
